package com.itheima.classTest;

import com.itheima.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class TestStudent {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
       Student s1 = getStudent(1);
       Student s2 = getStudent(2);
       Student s3 = getStudent(3);
        list.add(s1);
        list.add(s2);
        list.add(s3);
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            System.out.println(s);
        }
    }
    public static Student getStudent(int count){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第"+count+"学生姓名:");
        String name = sc.next();
        System.out.println("请输入第"+count+"学生年龄:");
        int age = sc.nextInt();
        Student s = new Student(name,age);
        return s;
    }
}
